package com.lg.erp.service.impl.zhangchaofu;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lg.erp.entity.zhangchaofu.CTCargo;
import com.lg.erp.mapper.zhangchaofu.CTCargoMapper;
import com.lg.erp.service.zhangchaofu.ICTCargoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CTCargoServiceImpl extends ServiceImpl<CTCargoMapper, CTCargo> implements ICTCargoService {

    @Autowired
    private CTCargoMapper cargoMapper;
    @Override
    public List<CTCargo> findCargo() {
        return cargoMapper.selectCargo();
    }

    @Override
    public IPage<CTCargo> findCargoPage(Page<CTCargo> page) {


        long size = page.getSize();
        long current = page.getCurrent();
        long start = (current-1)*(size);
        Integer cargoCount = cargoMapper.selectCargoCount(start,size);
        page.setTotal(cargoCount);
        page.setRecords(cargoMapper.selectCargoPage(start,size));
        return page;
    }

    @Override
    public int modifyCargoStatus(String id, String status) {
        return cargoMapper.updateStatusById(id,status);
    }

    @Override
    public List<CTCargo> searchCargo(String search) {
        return cargoMapper.selectSearchCargo(search);
    }

    @Override
    public int modifyCargoes(CTCargo tCargo) {
        return cargoMapper.updateCargoes(tCargo);
    }

    @Override
    public List<CTCargo> findInline(String shelvesNo, String cargoNo, String status) {
        return cargoMapper.selectInline(shelvesNo,cargoNo,status);
    }

    @Override
    public Integer findProductSumByProductNO(String productNo) {
        return cargoMapper.selectProductSumByProductNO(productNo);
    }
}
